package com.villaday.idf.activity;

import android.annotation.TargetApi;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Typeface;
import android.os.Build;
import android.os.Environment;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import androidx.appcompat.widget.LinearLayoutCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.appcompat.widget.Toolbar;
import android.text.Editable;
import android.text.Html;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.TextView;

import com.atuan.datepickerlibrary.CalendarUtil;
import com.atuan.datepickerlibrary.DatePopupWindow;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.villaday.idf.AppContext;
import com.villaday.idf.R;
import com.villaday.idf.adapter.BournFiltersSortAdapter;
import com.villaday.idf.adapter.BournFiltersTypeAdapter;
import com.villaday.idf.adapter.BournlistHeadAddrSortAdapter;
import com.villaday.idf.adapter2.FindHouseTagsAdapter;
import com.villaday.idf.adapter2.FindMinSulAdapter;
import com.villaday.idf.adapter2.FindMinSulChooseAddr1Adapter;
import com.villaday.idf.adapter2.FindMinSulChooseAddr2Adapter;
import com.villaday.idf.adapter2.FindMinSulChooseAddr3Adapter;
import com.villaday.idf.base.AbsRecyclerViewAdapter;
import com.villaday.idf.base.BaseActivity;
import com.villaday.idf.base.BaseDialog;
import com.villaday.idf.base.OnAdapterCallbackListener;
import com.villaday.idf.custom.CustomPopupWindow;
import com.villaday.idf.custom.DividerItemDecoration.RVItemDecoration;
import com.villaday.idf.custom.LoadingDialog;
import com.villaday.idf.custom.RangeSeekBar.OnRangeChangedListener;
import com.villaday.idf.custom.RangeSeekBar.RangeSeekBar;
import com.villaday.idf.custom.pop.ShareActivityNoWhitePop;
import com.villaday.idf.model.Cities_areasEntity;
import com.villaday.idf.model.Houses_filtersEntity;
import com.villaday.idf.model.VillagesEntity;
import com.villaday.idf.model2.Business_districts;
import com.villaday.idf.model2.Find_House_minsu_listEntity;
import com.villaday.idf.model2.Modules_find_house_configurations;
import com.villaday.idf.model3.AllPostersEntity;
import com.villaday.idf.util.Constant;
import com.villaday.idf.util.LogeUtil;
import com.villaday.idf.util.LongLogUtils;
import com.villaday.idf.util.OkHttpUtil;
import com.villaday.idf.util.PhoneUtil;
import com.villaday.idf.util.ShareUtils;
import com.villaday.idf.util.ShareUtilse;
import com.villaday.idf.util.ToastUtil;
import com.villaday.idf.util.ToolBarUtil;
import com.zhy.view.flowlayout.FlowLayout;
import com.zhy.view.flowlayout.TagAdapter;
import com.zhy.view.flowlayout.TagFlowLayout;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import butterknife.BindView;
import butterknife.OnClick;
import butterknife.OnEditorAction;
import byc.imagewatcher.ImageWatcher;
import io.reactivex.functions.Consumer;
import me.bakumon.statuslayoutmanager.library.OnStatusChildClickListener;
import me.bakumon.statuslayoutmanager.library.StatusLayoutManager;

/*
 * 民宿搜索结果页
 * */
public class MinsuSearchResultActivity extends BaseActivity implements OkHttpUtil.OnDataListener, View.OnClickListener, OnAdapterCallbackListener, AbsRecyclerViewAdapter.OnItemClickListener, SwipeRefreshLayout.OnRefreshListener, BaseDialog.OnItemClickListener, TextWatcher {

    @BindView(R.id.tv_default)
    TextView tvDefault;
    @BindView(R.id.tv_type)
    TextView tvType;
    @BindView(R.id.tv_more)
    TextView tvMore;
    @BindView(R.id.rv_dataList)
    RecyclerView rvDataList;
    @BindView(R.id.ll_addrSort)
    LinearLayout ll_addrSort;

    @BindView(R.id.tv_date)
    TextView tvDate;

    @BindView(R.id.rv_tag)
    RecyclerView rvTag;

    @BindView(R.id.srl)
    SwipeRefreshLayout srl;

    @BindView(R.id.tv_choseCity)
    TextView tv_choseCity;

    @BindView(R.id.toolbar_text)
    Toolbar toolbarText;

    @BindView(R.id.toolbar_searchBox)
    TextView toolbar_searchBox;

    private ImageWatcher vImageWatcher;
    private AllPostersEntity.BodyBean allPostersEntity;
    private int pageNo = 1;
    private int nextIndex = 1;
    private int pageSize = 10;
    private List<Cities_areasEntity.BodyEntity> qudatas = new ArrayList<>();
    private int currentAddPosition = -1;//当前区position

    private String villageId = "";//小区ID
    private String city = "";//城市名称(如:深圳)
    private String area = "";//区县名称(如:盐田区)
    private String types = "";//房源类型(0:别墅客栈,1:特色公寓,3:轰趴场馆,4:度假村,空值:全部)
    private String minPrice = "0";//最低价格
    private String maxPrice = "0";//最高价格
    private String minPeople = "0";//最低人数
    private String maxPeople = "0";//最高人数
    private String facilities = "";//设施选项(多项以逗号分隔)(如:泳池,温泉...)
    private String sortBy = "";//排序规则(price_asc:价格最高,price_desc:价格最低,空值:默认排序)

    private String scenicSpotId = "";
    private String businesId = "";
    private String stationId = "";
    private String subwayLineId = "";
    private String collegeId = "";


    private int minPriceCurrent = 0;
    private int maxPriceCurrent = 0;

    private int onChangeminPriceCurrent = 0;
    private int onChangemaxPriceCurrent = 0;

    private int peoplesCurrent = 0;
    private int onChangePeoplesCurrent = 0;

    private String words = "";
    private String tags = "";
    private String businessDistrictId = "";//为用addrId
    private String checkInDate = "";
    private String checkOutDate = "";


    private LoadingDialog loadingDialog;
    private Gson gson = new GsonBuilder().create();
    private VillagesEntity villagesEntity;

    private List<Find_House_minsu_listEntity.BodyEntity.ListEntity> data = new ArrayList();
    private FindMinSulAdapter bournDeticalAdapter;
    private Houses_filtersEntity houses_filtersEntity;
    private int currentSortPosition = -1;// 默认排序
    private int currentTypePosition = -1;// 房源类型

    private BournFiltersSortAdapter bournFiltersSortAdapter;
    private BournFiltersTypeAdapter bournFiltersTypeAdapter;
    private RangeSeekBar sideBar;
    Set<Integer> facilitiespositionS = new HashSet<Integer>();//设备选中的position  集合
    private TagAdapter<Houses_filtersEntity.BodyEntity.FiltersEntity.RoomsEntity> tagAdapter;
    private TagFlowLayout idFlowlayout;
    private View currentView;
    private StatusLayoutManager statusLayoutManager;
    private CharSequence[] tickMarkTextArray;

    private int startGroup = -1;
    private int endGroup = -1;
    private int startChild = -1;
    private int endChild = -1;
    private String addrId = "";//查询地区id

    private int firstAddrPosition = 0;//地址选择第一级选中position
    private int secondAddrPosition = 0;
    private int thirdAddrPosition = 0;
    private FindMinSulChooseAddr2Adapter findMinSulChooseAddr2Adapter;
    private FindHouseTagsAdapter findHouseTagsAdapter;
    private Modules_find_house_configurations modules_find_house_configurations;
    private BournlistHeadAddrSortAdapter bournlistHeadAddrSortAdapter;
    private Cities_areasEntity cities_areasEntity;
    private CustomPopupWindow popuAddr;
    private CustomPopupWindow popuaddr3Ji;
    private CustomPopupWindow popuSort;
    private CustomPopupWindow popuMore;
    private Business_districts business_districts;

    @Override
    protected int getViewResId() {
        return R.layout.activity_minsu_search_result;
    }

    public boolean onBack() {
        if (vImageWatcher == null) {
            return false;
        } else {
            // 当确认没有子Fragmnt时可以直接return false
            if (!vImageWatcher.handleBackPressed()) {
                return BackHandlerHelper.handleBackPress(this);
            } else {
                return !BackHandlerHelper.handleBackPress(this);
            }
        }


    }
    @Override
    public void onBackPressed() {

        if (!onBack()) {
            super.onBackPressed();
            Intent intent = new Intent(this, SearchMinSu2VActivity.class);
            intent.putExtra("cityId", AppContext.currentCityidCurrent);
            startActivityForResult(intent, 124);
        }
    }


    @Override
    protected void init() {
        initSharePop();
        initDate();
      /*  ToolBarUtil.initToolBar(toolbarText, getIntent().getBooleanExtra("isBieShu", false) ? "别墅" : "民宿", new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });*/
        tv_choseCity.setFocusable(true);
        tv_choseCity.setFocusableInTouchMode(true);
        toolbar_searchBox.addTextChangedListener(this);

        words = getIntent().getStringExtra("text");
        if (!TextUtils.isEmpty(words)) {
            toolbar_searchBox.setText(words);
        }
        ToolBarUtil.initToolBar(toolbarText, getIntent().getBooleanExtra("isBieShu", false) ? "房源列表" : "房源列表", new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });
        villageId = getIntent().getStringExtra("villageId");
        city = AppContext.cityCurrent;
        area = getIntent().getStringExtra("area");

        if (!TextUtils.isEmpty(area)) {
            tvType.setText(area);
        }

        scenicSpotId = getIntent().getStringExtra("scenicSpotId");
        businesId = getIntent().getStringExtra("businesId");
        stationId = getIntent().getStringExtra("stationId");
        subwayLineId = getIntent().getStringExtra("subwayLineId");
        collegeId = getIntent().getStringExtra("collegeId");
        addrId = getIntent().getStringExtra("businessDistrictId");

        tv_choseCity.setText(AppContext.cityCurrent);
        statusLayoutManager = setupDefaultStatusLayoutManager(ll_addrSort, new OnStatusChildClickListener() {
            @Override
            public void onEmptyChildClick(View view) {

            }

            @Override
            public void onErrorChildClick(View view) {
                loadingDialog = LoadingDialog.newInstance("加载中");
                loadingDialog.show(getFragmentManager(), "loading");

                loadData();
            }

            @Override
            public void onCustomerChildClick(View view) {

            }
        });
       /* //透明状态栏
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            Window window = getWindow();
            // Translucent status bar
            window.setFlags(
                    WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
                    WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        }

        StatusBarUtil.setTranslucentForImageViewInFragment(this, null);
        StatusBarUtil.setLightMode(this);*/


        loadingDialog = LoadingDialog.newInstance("加载中");
        loadingDialog.show(getFragmentManager(), "loading");

        srl.setOnRefreshListener(this);
        rvDataList.setLayoutManager(new LinearLayoutManager(this));
        bournDeticalAdapter = new FindMinSulAdapter(this, this, this);
        rvDataList.setAdapter(bournDeticalAdapter);

       // rvDataList.addItemDecoration(new RVItemDecoration(LinearLayout.VERTICAL, PhoneUtil.dp2px(this, 1), getResources().getColor(R.color.colorBg), PhoneUtil.dp2px(this, 1)));
        bournDeticalAdapter.setOnItemClickListener(this);
       /* View inflate = View.inflate(getContext(), R.layout.recycle_head, null);
        homeListSaleAdapter.addHeaderView(inflate);*/
        bournDeticalAdapter.setEmptyView(R.layout.empty_tips);
        bournDeticalAdapter.setEmptyTips(R.id.tv_emptyTips, "--暂无相关房源--");

        findHouseTagsAdapter = new FindHouseTagsAdapter(this);
        rvTag.setLayoutManager(new LinearLayoutManager(this, LinearLayout.HORIZONTAL, false));
        rvTag.addItemDecoration(new RVItemDecoration(LinearLayout.VERTICAL, PhoneUtil.dp2px(this, 1), getResources().getColor(R.color.colorBg), PhoneUtil.dp2px(this, 1)));
        findHouseTagsAdapter.setFullScreen(true);
        rvTag.setAdapter(findHouseTagsAdapter);
        findHouseTagsAdapter.setOnItemClickListener(new AbsRecyclerViewAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(View v, int position) {
                modules_find_house_configurations.getBody().getTags().get(position).setCheck(!modules_find_house_configurations.getBody().getTags().get(position).isCheck());
                findHouseTagsAdapter.notifyDataSetChanged();
                loadingDialog = LoadingDialog.newInstance("加载中");
                loadingDialog.show(getFragmentManager(), "loading");
                onRefresh();
            }
        });

    }

    @Override
    public void onResume() {
        super.onResume();
        initDate();
    }

    private void initDate() {
        try {
            if (TextUtils.isEmpty(AppContext.checkInDate)){
                tvDate.setText(Html.fromHtml(String.format(getResources().getString(R.string.datetext),"住","不限" + "\n","离","不限")));

            }else {
                checkInDate = AppContext.checkInDate;
                checkOutDate = AppContext.checkOutDate;

                startGroup = AppContext.startGroup;
                startChild = AppContext.startChild;
                endGroup = AppContext.endGroup;
                endChild =AppContext.endChild;


                String mStartTime = CalendarUtil.FormatDate_MD(checkInDate);
                String mEndTime = CalendarUtil.FormatDate_MD(checkOutDate);
                tvDate.setText(Html.fromHtml(String.format(getResources().getString(R.string.datetext), "住", mStartTime + "\n", "离", mEndTime)));

            }
        } catch (Exception e) {
            e.printStackTrace();
            LongLogUtils.e("eee", e.getMessage());
        }
    }

    @OnEditorAction(R.id.toolbar_searchBox)
    public boolean onEditAction(TextView v, int actionId, KeyEvent event) {
        if (actionId == EditorInfo.IME_ACTION_SEARCH || (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
            //ToastUtil.initToast(this, "hhhh");
            PhoneUtil.hideKeyboard(v);
            CharSequence text = v.getText();
            if (!TextUtils.isEmpty(text)) {
                minPriceCurrent = 0;
                if (tickMarkTextArray != null && tickMarkTextArray.length >= 1) {
                    maxPriceCurrent = tickMarkTextArray.length - 1;

                }
                peoplesCurrent = 0;

                onChangePeoplesCurrent = 0;
                facilitiespositionS.clear();
                if (tagAdapter != null) {
                    tagAdapter.setSelectedList(facilitiespositionS);

                }

                words = text.toString();

            } else {
                words = "";

            }
            loadData();


            return true;
        }
        return false;
    }

    @Override
    protected void loadData() {
        //OkHttpUtil.getJSON(this, String.format(Constant.URL.villages, villageId), this);

        getHouseList();
        //头部标签
        loadHeadTags();
    }

    protected void loadHeadTags() {
        // OkHttpUtil.getJSON(this, Constant.URL.modules_find_house_configurations, this);
        HashMap<String, String> map = new HashMap<>();
        map.put("type", getIntent().getBooleanExtra("isBieShu", false) ? "2" : "1");

        OkHttpUtil.getJSON(this, Constant.URL.modules_search_result_configurations, map, this);


    }

    private void getHouseList() {
        //价格
        if (houses_filtersEntity != null &&
                houses_filtersEntity.getBody() != null &&
                houses_filtersEntity.getBody().getFilters() != null &&
                houses_filtersEntity.getBody().getFilters().getPrices() != null) {
            minPrice = houses_filtersEntity.getBody().getFilters().getPrices().get(minPriceCurrent).getName();

            if (maxPriceCurrent == houses_filtersEntity.getBody().getFilters().getPrices().size() - 1) {
                maxPrice = "0";

            } else {
                maxPrice = houses_filtersEntity.getBody().getFilters().getPrices().get(maxPriceCurrent).getName();


            }
        }
        //人数
        if (houses_filtersEntity != null &&
                houses_filtersEntity.getBody() != null &&
                houses_filtersEntity.getBody().getFilters() != null &&
                houses_filtersEntity.getBody().getFilters().getPeoples() != null) {
            minPeople = houses_filtersEntity.getBody().getFilters().getPeoples().get(peoplesCurrent).getId();


        }
       /* //设施
        if (houses_filtersEntity != null &&
                houses_filtersEntity.getBody() != null &&
                houses_filtersEntity.getBody().getFilters() != null &&
                houses_filtersEntity.getBody().getFilters().getFacilities() != null) {

            facilities = "";
            for (Integer str : facilitiespositionS) {
                facilities = facilities + houses_filtersEntity.getBody().getFilters().getFacilities().get(str).getId() + ",";
            }
            if (!TextUtils.isEmpty(facilities)) {
                facilities = facilities.substring(0, facilities.length() - 1);
            }
        }*/
        //设施
        if (houses_filtersEntity != null &&
                houses_filtersEntity.getBody() != null &&
                houses_filtersEntity.getBody().getFilters() != null &&
                houses_filtersEntity.getBody().getFilters().getRooms() != null) {

            facilities = "";
            for (Integer str : facilitiespositionS) {
                facilities = facilities + houses_filtersEntity.getBody().getFilters().getRooms().get(str).getId() + ",";
            }
            if (!TextUtils.isEmpty(facilities)) {
                facilities = facilities.substring(0, facilities.length() - 1);
            }
        }

        if (modules_find_house_configurations != null && modules_find_house_configurations.getBody() != null && modules_find_house_configurations.getBody().getTags() != null) {
            tags = "";
            for (int j = 0; j < modules_find_house_configurations.getBody().getTags().size(); j++) {
                if (modules_find_house_configurations.getBody().getTags().get(j).isCheck()) {
                    tags = tags + modules_find_house_configurations.getBody().getTags().get(j).getId() + ",";

                }

            }
            if (!TextUtils.isEmpty(tags)) {
                tags = tags.substring(0, tags.length() - 1);
            }
        }
        Map<String, String> map = new HashMap<>();
        map.put("villageId", villageId);
        map.put("city", city);
      //  map.put("area", "全部".equals(area)?"":area);
        map.put("types", types);
        map.put("minPrice", minPrice);
        map.put("maxPrice", maxPrice);
        map.put("minPeople", minPeople);
        map.put("maxPeople", maxPeople);
        //   map.put("facilities", facilities);
        map.put("rooms", facilities);
        map.put("sortBy", sortBy);
        map.put("pageNo", pageNo + "");
        map.put("pageSize", pageSize + "");

        map.put("scenicSpotId", scenicSpotId);
        map.put("businesId", businesId);
        map.put("stationId", stationId);
        map.put("subwayLineId", subwayLineId);
        map.put("collegeId", collegeId);
        map.put("words", words);

        map.put("businessDistrictId", addrId);
        map.put("checkInDate", checkInDate);
        map.put("checkOutDate", checkOutDate);
        map.put("tags", tags);


        if (!getIntent().getBooleanExtra("isBieShu", false)) {
            map.put("searchType", "1");
        }


        OkHttpUtil.getJSON(this, Constant.URL.houses_list, map, this);

    }

    @OnClick({R.id.toolbar_searchBox, R.id.tv_date, R.id.tv_type, R.id.tv_choseCity})
    public void onViewClickedChooseDate(View view) {

        switch (view.getId()) {
            case R.id.toolbar_searchBox: {//调回去
                if (getIntent().getBooleanExtra("isBieShu", false)) {
                    /*Intent intent = new Intent(this, SearchBieShu2VActivity.class);
                    intent.putExtra("cityId", AppContext.currentCityidCurrent);
                    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                    startActivity(intent);*/
                    onBackPressed();
                } else {
                   /* Intent intent = new Intent(this, SearchMinSu2VActivity.class);
                    intent.putExtra("cityId", AppContext.currentCityidCurrent);

                    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                    startActivity(intent);*/

                    onBackPressed();
                }


            }
            break;
            case R.id.tv_choseCity: {//搜索城市
                diasspopu();
                Intent intent = new Intent(this, ChooseCityActity.class);
                intent.putExtra("cityId", AppContext.currentCityidCurrent);
                intent.putExtra("type", "1");
                startActivityForResult(intent, 123);
            }

            break;
            case R.id.tv_date: {
                createCustomDatePicker(view, tvDate);
            }
            break;
            case R.id.tv_type: {

                if (getIntent().getBooleanExtra("isBieShu", false)) {
                    popuAddr();


                } else {
                    if (popuMore != null && popuMore.getPopupWindow() != null) {
                        popuMore.getPopupWindow().dismiss();
                        popuMore = null;

                    }
                    if (popuSort != null && popuSort.getPopupWindow() != null) {
                        popuSort.getPopupWindow().dismiss();
                        popuSort = null;

                    }
                    if (popuAddr != null && popuAddr.getPopupWindow() != null) {
                        popuAddr.getPopupWindow().dismiss();
                        popuAddr = null;


                    }
                    if (popuaddr3Ji != null && popuaddr3Ji.getPopupWindow() != null) {
                        popuaddr3Ji.getPopupWindow().dismiss();
                        popuaddr3Ji = null;
                        return;
                    }
                    loadingDialog = LoadingDialog.newInstance("加载中");
                    loadingDialog.show(getFragmentManager(), "loading");
                    OkHttpUtil.getJSON(this, Constant.URL.business_districts, this);
                }
            }


            break;
        }


    }


    //日历
    private void createCustomDatePicker(View view, final TextView result) {
        new DatePopupWindow
                .Builder(this, Calendar.getInstance().getTime(), view)
                .setInitSelect(startGroup, startChild, endGroup, endChild)

                //.setInitSelect(-1, -1, -1, -1)
                .setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        if (v.getId() == R.id.btn_clear) {
                            checkInDate = "";
                            checkOutDate = "";
                            startGroup = -1;
                            startChild = -1;
                            endGroup = -1;
                            endChild = -1;

                            AppContext.checkInDate = "";
                            AppContext.checkOutDate = "";
                            AppContext.startGroup = -1;
                            AppContext.startChild = -1;
                            AppContext.endGroup = -1;
                            AppContext.endChild = -1;
                            result.setText(Html.fromHtml(String.format(getResources().getString(R.string.datetext),"住","不限" + "\n","离","不限")));
                            onRefresh();
                        }
                    }
                })
                .setInitDay(false)
                .setDateOnClickListener(new DatePopupWindow.DateOnClickListener() {
                    @Override
                    public void getDate(String startDate, String endDate, int startGroupPosition, int startChildPosition, int endGroupPosition, int endChildPosition) {
                        startGroup = startGroupPosition;
                        startChild = startChildPosition;
                        endGroup = endGroupPosition;
                        endChild = endChildPosition;

                        checkInDate = startDate;
                        checkOutDate = endDate;
                        AppContext.startGroup = startGroup;
                        AppContext.startChild = startChild;
                        AppContext.endGroup = endGroup;
                        AppContext.endChild = endChild;
                        AppContext.checkInDate = checkInDate;
                        AppContext.checkOutDate = checkOutDate;

                        String mStartTime = CalendarUtil.FormatDate_MD(startDate);
                        String mEndTime = CalendarUtil.FormatDate_MD(endDate);
                        result.setText(Html.fromHtml(String.format(getResources().getString(R.string.datetext),"住",mStartTime + "\n","离",mEndTime)));
                        onRefresh();
                    }
                }).builder();
    }

    @OnClick({R.id.tv_default, /*R.id.tv_type,*/ R.id.tv_more})
    public void onViewClicked(View view) {

        if (houses_filtersEntity == null || houses_filtersEntity.getBody() == null || !"200".equals(houses_filtersEntity.getCode())) {
            loadingDialog = LoadingDialog.newInstance("加载中");
            loadingDialog.show(getFragmentManager(), "loading");
            OkHttpUtil.getJSON(this, Constant.URL.houses_filters, this);
            currentView = view;

        } else {
            getMore(view);
        }


    }

    //普通区域列表
    private void popuAddr() {
        if (popuaddr3Ji != null && popuaddr3Ji.getPopupWindow() != null) {
            popuaddr3Ji.getPopupWindow().dismiss();
            popuaddr3Ji = null;
        }
        if (popuMore != null && popuMore.getPopupWindow() != null) {
            popuMore.getPopupWindow().dismiss();
            popuMore = null;

        }
        if (popuSort != null && popuSort.getPopupWindow() != null) {
            popuSort.getPopupWindow().dismiss();
            popuSort = null;

        }
        if (popuAddr != null && popuAddr.getPopupWindow() != null) {
            popuAddr.getPopupWindow().dismiss();
            popuAddr = null;
            return;

        }
        tvType.setSelected(true);
        loadingDialog = LoadingDialog.newInstance("加载中");
        loadingDialog.show(getFragmentManager(), "loading");
        OkHttpUtil.getJSON(this, String.format(Constant.URL.cities_areas, AppContext.currentCityidCurrent), this);


    }


    private void popuSort() {
        if (popuaddr3Ji != null && popuaddr3Ji.getPopupWindow() != null) {
            popuaddr3Ji.getPopupWindow().dismiss();
            popuaddr3Ji = null;
        }
        if (popuMore != null && popuMore.getPopupWindow() != null) {
            popuMore.getPopupWindow().dismiss();
            popuMore = null;

        }
        if (popuAddr != null && popuAddr.getPopupWindow() != null) {
            popuAddr.getPopupWindow().dismiss();
            popuAddr = null;


        }
        if (popuSort != null && popuSort.getPopupWindow() != null) {
            popuSort.getPopupWindow().dismiss();
            popuSort = null;
            return;
        }
        tvDefault.setSelected(true);

        popuSort = new CustomPopupWindow.Builder().setheight(LinearLayoutCompat.LayoutParams.MATCH_PARENT)
                .setwidth(LinearLayoutCompat.LayoutParams.MATCH_PARENT)
                .setOutSideCancel(false)
                .setContext(this)
                .setActivity(this)
                .isBlur(true)
                .setRadius(5)
                .setContentView(R.layout.popu_bourn_head_chose_addr_sort)
                .setOnDismissListener(new PopupWindow.OnDismissListener() {
                    @Override
                    public void onDismiss() {
                        tvDefault.setSelected(false);
                    }
                })
                .builder();

        popuSort.getItemView(R.id.close).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                popuSort.dismiss();
                if (popuaddr3Ji != null && popuaddr3Ji.getPopupWindow() != null) {
                    popuaddr3Ji.getPopupWindow().dismiss();
                    popuaddr3Ji = null;
                }
                if (popuMore != null && popuMore.getPopupWindow() != null) {
                    popuMore.getPopupWindow().dismiss();
                    popuMore = null;

                }
                if (popuSort != null && popuSort.getPopupWindow() != null) {
                    popuSort.getPopupWindow().dismiss();
                    popuSort = null;

                }
                if (popuAddr != null && popuAddr.getPopupWindow() != null) {
                    popuAddr.getPopupWindow().dismiss();
                    popuAddr = null;

                }
            }
        });


        popuSort.showAsLaction(ll_addrSort, Gravity.BOTTOM, 0, 0);


        RecyclerView rvAddr = (RecyclerView) popuSort.getItemView(R.id.rv_addr_sort);
        rvAddr.setLayoutManager(new LinearLayoutManager(this));
        if (bournFiltersSortAdapter == null) {
            bournFiltersSortAdapter = new BournFiltersSortAdapter(this);

        }
        if (houses_filtersEntity != null && houses_filtersEntity.getBody() != null && "200".equals(houses_filtersEntity.getCode())) {
            bournFiltersSortAdapter.setData(houses_filtersEntity.getBody().getSorts());
        }
        rvAddr.setAdapter(bournFiltersSortAdapter);

        rvAddr.addItemDecoration(new RVItemDecoration(LinearLayout.VERTICAL, PhoneUtil.dp2px(this, 1), getResources().getColor(R.color.colorBg), PhoneUtil.dp2px(this, 8)));
        if (currentSortPosition == -1) {
            houses_filtersEntity.getBody().getSorts().get(0).setCheck(true);

        }
        bournFiltersSortAdapter.setOnItemClickListener(new AbsRecyclerViewAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(View v, int position) {
                popuSort.dismiss();
                if (popuaddr3Ji != null && popuaddr3Ji.getPopupWindow() != null) {
                    popuaddr3Ji.getPopupWindow().dismiss();
                    popuaddr3Ji = null;
                }
                if (popuMore != null && popuMore.getPopupWindow() != null) {
                    popuMore.getPopupWindow().dismiss();
                    popuMore = null;

                }
                if (popuSort != null && popuSort.getPopupWindow() != null) {
                    popuSort.getPopupWindow().dismiss();
                    popuSort = null;

                }
                if (popuAddr != null && popuAddr.getPopupWindow() != null) {
                    popuAddr.getPopupWindow().dismiss();
                    popuAddr = null;

                }
                if (houses_filtersEntity != null && houses_filtersEntity.getBody() != null) {
                    houses_filtersEntity.getBody().getSorts().get(position).setCheck(!houses_filtersEntity.getBody().getSorts().get(position).isCheck());
                    if (currentSortPosition == -1) {
                        houses_filtersEntity.getBody().getSorts().get(0).setCheck(false);

                    }
                    if (currentSortPosition != -1 && currentSortPosition != position) {
                        houses_filtersEntity.getBody().getSorts().get(currentSortPosition).setCheck(!houses_filtersEntity.getBody().getSorts().get(currentSortPosition).isCheck());

                    }
                    if (houses_filtersEntity.getBody().getSorts().get(position).isCheck()) {
                        sortBy = houses_filtersEntity.getBody().getSorts().get(position).getId();

                        tvDefault.setText(houses_filtersEntity.getBody().getSorts().get(position).getName());
                        currentSortPosition = position;
                    } else {
                        tvDefault.setText("默认排序");

                        sortBy = "";
                        currentSortPosition = -1;

                    }
                    bournFiltersSortAdapter.notifyDataSetChanged();
                    loadingDialog = LoadingDialog.newInstance("加载中");
                    loadingDialog.show(getFragmentManager(), "loading");
                    onRefresh();
                }

            }
        });
       /* View inflate = View.inflate(getContext(), R.layout.recycle_head, null);
        homeListSaleAdapter.addHeaderView(inflate);*/
        bournFiltersSortAdapter.setEmptyView(R.layout.empty_tips);
        bournFiltersSortAdapter.setEmptyTips(R.id.tv_emptyTips, "没有更多了");
    }

    private void popuMore() {
        if (popuaddr3Ji != null && popuaddr3Ji.getPopupWindow() != null) {
            popuaddr3Ji.getPopupWindow().dismiss();
            popuaddr3Ji = null;
        }
        if (popuSort != null && popuSort.getPopupWindow() != null) {
            popuSort.getPopupWindow().dismiss();
            popuSort = null;

        }
        if (popuAddr != null && popuAddr.getPopupWindow() != null) {
            popuAddr.getPopupWindow().dismiss();
            popuAddr = null;


        }
        if (popuMore != null && popuMore.getPopupWindow() != null) {
            popuMore.getPopupWindow().dismiss();
            popuMore = null;
            return;
        }
        tvMore.setSelected(true);
        popuMore = new CustomPopupWindow.Builder().setheight(LinearLayoutCompat.LayoutParams.MATCH_PARENT)
                .setwidth(LinearLayoutCompat.LayoutParams.MATCH_PARENT)
                .setOutSideCancel(false)
                .setContext(this)
                .setActivity(this)
                .isBlur(true)
                .setRadius(5)
                .setContentView(R.layout.popu_choose_more_huxing)
                .setOnDismissListener(new PopupWindow.OnDismissListener() {
                    @Override
                    public void onDismiss() {
                        tvMore.setSelected(false);
                    }
                })
                .builder();

        popuMore.getItemView(R.id.close).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                popuMore.dismiss();
                if (popuaddr3Ji != null && popuaddr3Ji.getPopupWindow() != null) {
                    popuaddr3Ji.getPopupWindow().dismiss();
                    popuaddr3Ji = null;
                }
                if (popuMore != null && popuMore.getPopupWindow() != null) {
                    popuMore.getPopupWindow().dismiss();
                    popuMore = null;

                }
                if (popuSort != null && popuSort.getPopupWindow() != null) {
                    popuSort.getPopupWindow().dismiss();
                    popuSort = null;

                }
                if (popuAddr != null && popuAddr.getPopupWindow() != null) {
                    popuAddr.getPopupWindow().dismiss();
                    popuAddr = null;

                }
            }
        });


        if (houses_filtersEntity != null && houses_filtersEntity.getBody() != null && "200".equals(houses_filtersEntity.getCode())) {
            popuMore.showAsLaction(ll_addrSort, Gravity.BOTTOM, 0, 0);

            //价格
            sideBar = (RangeSeekBar) popuMore.getItemView(R.id.sideBar);
            sideBar.setTypeface(Typeface.DEFAULT_BOLD);
            sideBar.getLeftSeekBar().setTypeface(Typeface.DEFAULT_BOLD);
            sideBar.setOnRangeChangedListener(new OnRangeChangedListener() {
                @Override
                public void onRangeChanged(RangeSeekBar view, float leftValue, float rightValue, boolean isFromUser) {
                    onChangeminPriceCurrent = (int) leftValue;
                    onChangemaxPriceCurrent = (int) rightValue;
                }

                @Override
                public void onStartTrackingTouch(RangeSeekBar view, boolean isLeft) {

                }

                @Override
                public void onStopTrackingTouch(RangeSeekBar view, boolean isLeft) {

                }
            });
            sideBar.setTickMarkNumber(houses_filtersEntity.getBody().getFilters().getPrices().size() - 1);
            tickMarkTextArray = new CharSequence[houses_filtersEntity.getBody().getFilters().getPrices().size()];
            sideBar.setRangeInterval(100f / (houses_filtersEntity.getBody().getFilters().getPrices().size() - 1));
            for (int i = 0; i < houses_filtersEntity.getBody().getFilters().getPrices().size(); i++) {
                tickMarkTextArray[i] = houses_filtersEntity.getBody().getFilters().getPrices().get(i).getName();
            }
            sideBar.setTickMarkTextArray(tickMarkTextArray);
            if (maxPriceCurrent == 0) {
                maxPriceCurrent = tickMarkTextArray.length - 1;
                onChangemaxPriceCurrent = maxPriceCurrent;

            }
            sideBar.setValue(minPriceCurrent, maxPriceCurrent);


            //重置按钮
            final TextView peoples = (TextView) popuMore.getItemView(R.id.tv_peoples);

            popuMore.getItemView(R.id.tv_reset).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    minPriceCurrent = 0;
                    maxPriceCurrent = tickMarkTextArray.length - 1;
                    peoplesCurrent = 0;
                    onChangePeoplesCurrent = 0;
                    facilitiespositionS.clear();
                    tagAdapter.setSelectedList(facilitiespositionS);
                    sideBar.setValue(minPriceCurrent, maxPriceCurrent);
                    peoples.setText(houses_filtersEntity.getBody().getFilters().getPeoples().get(onChangePeoplesCurrent).getName());


                    loadingDialog = LoadingDialog.newInstance("加载中");
                    loadingDialog.show(getFragmentManager(), "loading");
                    onRefresh();
                   /* popuMore.dismiss();
                    if (popuaddr3Ji != null && popuaddr3Ji.getPopupWindow() != null) {
                        popuaddr3Ji.getPopupWindow().dismiss();
                        popuaddr3Ji = null;
                    }
                    if (popuMore != null && popuMore.getPopupWindow() != null) {
                        popuMore.getPopupWindow().dismiss();
                        popuMore = null;

                    }
                    if (popuSort != null && popuSort.getPopupWindow() != null) {
                        popuSort.getPopupWindow().dismiss();
                        popuSort = null;

                    }
                    if (popuAddr != null && popuAddr.getPopupWindow() != null) {
                        popuAddr.getPopupWindow().dismiss();
                        popuAddr = null;

                    }*/
                }
            });


            //确定按钮

            popuMore.getItemView(R.id.tv_confirm).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    minPriceCurrent = onChangeminPriceCurrent;
                    maxPriceCurrent = onChangemaxPriceCurrent;
                    peoplesCurrent = onChangePeoplesCurrent;
                    facilitiespositionS.clear();
                    facilitiespositionS.addAll(idFlowlayout.getSelectedList());
                    loadingDialog = LoadingDialog.newInstance("加载中");
                    loadingDialog.show(getFragmentManager(), "loading");
                    onRefresh();
                    popuMore.dismiss();
                    if (popuaddr3Ji != null && popuaddr3Ji.getPopupWindow() != null) {
                        popuaddr3Ji.getPopupWindow().dismiss();
                        popuaddr3Ji = null;
                    }
                    if (popuMore != null && popuMore.getPopupWindow() != null) {
                        popuMore.getPopupWindow().dismiss();
                        popuMore = null;

                    }
                    if (popuSort != null && popuSort.getPopupWindow() != null) {
                        popuSort.getPopupWindow().dismiss();
                        popuSort = null;

                    }
                    if (popuAddr != null && popuAddr.getPopupWindow() != null) {
                        popuAddr.getPopupWindow().dismiss();
                        popuAddr = null;

                    }
                }
            });
            // 出行人数
            //final TextView peoples = (TextView) popuMore.getItemView(R.id.tv_peoples);
            peoples.setText(houses_filtersEntity.getBody().getFilters().getPeoples().get(peoplesCurrent).getName());
            onChangePeoplesCurrent = peoplesCurrent;
            // 出行人数减
            popuMore.getItemView(R.id.img_minus).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (onChangePeoplesCurrent == 0) {
                        onChangePeoplesCurrent = houses_filtersEntity.getBody().getFilters().getPeoples().size() - 1;

                    } else {
                        onChangePeoplesCurrent = onChangePeoplesCurrent - 1;

                    }
                    peoples.setText(houses_filtersEntity.getBody().getFilters().getPeoples().get(onChangePeoplesCurrent).getName());

                }
            });
            // 出行人数加

            popuMore.getItemView(R.id.img_plus).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (onChangePeoplesCurrent == houses_filtersEntity.getBody().getFilters().getPeoples().size() - 1) {
                        onChangePeoplesCurrent = 0;

                    } else {
                        onChangePeoplesCurrent = onChangePeoplesCurrent + 1;

                    }
                    peoples.setText(houses_filtersEntity.getBody().getFilters().getPeoples().get(onChangePeoplesCurrent).getName());

                }
            });

            //设施
            idFlowlayout = (TagFlowLayout) popuMore.getItemView(R.id.id_flowlayout);


            tagAdapter = new TagAdapter<Houses_filtersEntity.BodyEntity.FiltersEntity.RoomsEntity>(houses_filtersEntity.getBody().getFilters().getRooms()) {
                @Override
                public View getView(FlowLayout parent, int position, Houses_filtersEntity.BodyEntity.FiltersEntity.RoomsEntity s) {
                    TextView tv = (TextView) getLayoutInflater().inflate(R.layout.tv_22_have_sheshi,
                            idFlowlayout, false);
                    tv.setText(s.getName());

                    return tv;
                }
            };
            idFlowlayout.setAdapter(tagAdapter);
            if (facilitiespositionS.size() != 0) {

                tagAdapter.setSelectedList(facilitiespositionS);
            }


            idFlowlayout.setOnTagClickListener(new TagFlowLayout.OnTagClickListener() {
                @Override
                public boolean onTagClick(View view, int position, FlowLayout parent) {

                    return true;
                }
            });
        }
    }

    //初始化地址选择
    private void initAddr3ji(final List<Business_districts.BodyEntity> body) {


        if (popuMore != null && popuMore.getPopupWindow() != null) {
            popuMore.getPopupWindow().dismiss();
            popuMore = null;

        }
        if (popuSort != null && popuSort.getPopupWindow() != null) {
            popuSort.getPopupWindow().dismiss();
            popuSort = null;
        }
        if (popuAddr != null) {
            popuAddr.getPopupWindow().dismiss();
            popuAddr = null;
        }
        if (popuaddr3Ji != null && popuaddr3Ji.getPopupWindow() != null) {
            popuaddr3Ji.getPopupWindow().dismiss();
            popuaddr3Ji = null;
            return;

        }
        tvType.setSelected(true);
        popuaddr3Ji = new CustomPopupWindow.Builder().setheight(LinearLayoutCompat.LayoutParams.MATCH_PARENT)
                .setwidth(LinearLayoutCompat.LayoutParams.MATCH_PARENT)
                .setOutSideCancel(false)
                .setActivity(this)
                .isBlur(true)
                .setRadius(5)
                .setContext(this)
                .setContentView(R.layout.popu_find_minsu_chose_addr)
                .setOnDismissListener(new PopupWindow.OnDismissListener() {
                    @Override
                    public void onDismiss() {
                        tvType.setSelected(false);
                    }
                })
                .builder();

        popuaddr3Ji.getItemView(R.id.close).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                popuaddr3Ji.dismiss();
                diasspopu();
            }
        });


        popuaddr3Ji.showAsLaction(ll_addrSort, Gravity.BOTTOM, 0, 0);


//一级
        RecyclerView rv1 = (RecyclerView) popuaddr3Ji.getItemView(R.id.rv1);
        rv1.setLayoutManager(new LinearLayoutManager(this));
        final FindMinSulChooseAddr1Adapter findMinSulChooseAddr1Adapter = new FindMinSulChooseAddr1Adapter(this);
        rv1.setAdapter(findMinSulChooseAddr1Adapter);
        findMinSulChooseAddr1Adapter.setData(body);
//二级
        final RecyclerView rv2 = (RecyclerView) popuaddr3Ji.getItemView(R.id.rv2);
        rv2.setLayoutManager(new LinearLayoutManager(this));
        findMinSulChooseAddr2Adapter = new FindMinSulChooseAddr2Adapter(this, false);
        rv2.setAdapter(findMinSulChooseAddr2Adapter);

        //三级
        final RecyclerView rv3 = (RecyclerView) popuaddr3Ji.getItemView(R.id.rv3);
        rv3.setLayoutManager(new LinearLayoutManager(this));
        final FindMinSulChooseAddr3Adapter findMinSulChooseAddr3Adapter = new FindMinSulChooseAddr3Adapter(this);
        rv3.setAdapter(findMinSulChooseAddr3Adapter);


        findMinSulChooseAddr3Adapter.setOnItemClickListener(new AbsRecyclerViewAdapter.OnItemClickListener() {

            @Override
            public void onItemClick(View v, int position) {


                thirdAddrPosition = position;

                body.get(firstAddrPosition).getChildren().get(secondAddrPosition).getChildren().get(thirdAddrPosition).setSelect(true);

                List<Business_districts.BodyEntity.ChildrenEntity.ChildrenEntity1> children = body.get(firstAddrPosition).getChildren().get(secondAddrPosition).getChildren();
                addrId = children.get(thirdAddrPosition).getId();
                if (position == 0) {
                    tvType.setText("位置区域");
                    addrId="";
                    area = "";
                } else {
                    tvType.setText(children.get(thirdAddrPosition).getName().length() > 5 ? children.get(thirdAddrPosition).getName().substring(0, 5) + "..." : children.get(thirdAddrPosition).getName());
                }
                findMinSulChooseAddr3Adapter.notifyDataSetChanged();
                popuaddr3Ji.dismiss();
                diasspopu();


                /*firstAddrPosition = 0;
                secondAddrPosition = 0;
                thirdAddrPosition = 0;*/

                onRefresh();

            }
        });
        //只有二级
        findMinSulChooseAddr2Adapter.setOnItemClickListener(new AbsRecyclerViewAdapter.OnItemClickListener() {

            @Override
            public void onItemClick(View v, int position) {

                if (secondAddrPosition != -1) {
                    body.get(firstAddrPosition).getChildren().get(secondAddrPosition).setSelect(false);

                    findMinSulChooseAddr2Adapter.notifyDataSetChanged();

                }

                secondAddrPosition = position;

                if (body.get(firstAddrPosition).getChildren().get(secondAddrPosition).getChildren() != null && body.get(firstAddrPosition).getChildren().get(secondAddrPosition).getChildren().size() >= 0) {
                    for (int j = 0; j < body.get(firstAddrPosition).getChildren().get(secondAddrPosition).getChildren().size(); j++) {
                        body.get(firstAddrPosition).getChildren().get(secondAddrPosition).getChildren().get(j).setSelect(false);

                    }
                }

                body.get(firstAddrPosition).getChildren().get(secondAddrPosition).setSelect(true);
                Business_districts.BodyEntity.ChildrenEntity childrenEntity = body.get(firstAddrPosition).getChildren().get(secondAddrPosition);

                findMinSulChooseAddr2Adapter.notifyDataSetChanged();

                if (childrenEntity.getChildren() != null && childrenEntity.getChildren().size() != 0) {
                    rv3.setAdapter(findMinSulChooseAddr3Adapter);
                    findMinSulChooseAddr3Adapter.setData(childrenEntity.getChildren());
                    rv3.setVisibility(View.VISIBLE);
                } else {
                    rv3.setVisibility(View.GONE);
                    addrId = childrenEntity.getId();
                    if (position == 0) {
                        thirdAddrPosition=0;
                        tvType.setText("位置区域");
                        addrId="";
                        area = "";
                    } else {
                        tvType.setText(childrenEntity.getName().length() > 5 ? childrenEntity.getName().substring(0, 5) + "..." : childrenEntity.getName());
                    }
                    popuaddr3Ji.dismiss();
                    diasspopu();
                                /*firstAddrPosition = 0;
                                secondAddrPosition = 0;*/
                    onRefresh();
                }


            }
        });
        findMinSulChooseAddr1Adapter.setOnItemClickListener(new AbsRecyclerViewAdapter.OnItemClickListener() {


            @Override
            public void onItemClick(View v, int position) {

                if (firstAddrPosition != -1) {
                    body.get(firstAddrPosition).setSelect(false);

                }
                firstAddrPosition = position;
                for (int j = 0; j <body.get(firstAddrPosition).getChildren().size();  j++) {
                    body.get(firstAddrPosition).getChildren().get(j).setSelect(false);

                }
                body.get(firstAddrPosition).setSelect(true);

                findMinSulChooseAddr1Adapter.notifyDataSetChanged();
                boolean isHaveThird = false;

                if (body.get(position).getChildren() != null && body.get(position).getChildren().size() != 0) {

                    for (int j = 0; j < body.get(position).getChildren().size(); j++) {
                        if (body.get(position).getChildren().get(j).getChildren() != null && body.get(position).getChildren().get(j).getChildren().size() != 0) {
                            isHaveThird = true;


                            break;
                        }
                    }
                    if (isHaveThird) {
                        rv3.setVisibility(View.VISIBLE);
                    } else {
                        rv3.setVisibility(View.GONE);
                    }

                    findMinSulChooseAddr2Adapter.setData(body.get(position).getChildren());

                }
            }
        });
        if (!TextUtils.isEmpty(addrId)) {
            for (int j = 0; j < body.size(); j++) {
                if (body.get(j).getChildren() != null && (body.get(j).getChildren().size() > 0)) {
                    for (int k = 0; k < body.get(j).getChildren().size(); k++) {
                        if (addrId.equals(body.get(j).getChildren().get(k).getId())) {
                            firstAddrPosition = j;
                            secondAddrPosition = k;
                            break;
                        } else {
                            if (body.get(j).getChildren().get(k).getChildren() != null && (body.get(j).getChildren().get(k).getChildren().size() > 0)) {
                                for (int l = 0; l < body.get(j).getChildren().get(k).getChildren().size(); l++) {
                                    if (addrId.equals(body.get(j).getChildren().get(k).getChildren().get(l).getId())) {
                                        firstAddrPosition = j;
                                        secondAddrPosition = k;
                                        thirdAddrPosition = l;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }


            }
        }
        if (firstAddrPosition != -1) {
            if (business_districts.getBody() != null && business_districts.getBody().size() > 0) {
                business_districts.getBody().get(firstAddrPosition).setSelect(true);
                findMinSulChooseAddr3Adapter.notifyDataSetChanged();
                rv1.scrollToPosition(firstAddrPosition);

                if (secondAddrPosition != -1 && business_districts.getBody().get(firstAddrPosition).getChildren() != null && business_districts.getBody().get(firstAddrPosition).getChildren().size() > 0) {
                    business_districts.getBody().get(firstAddrPosition).getChildren().get(secondAddrPosition).setSelect(true);

                    findMinSulChooseAddr2Adapter.setData((body.get(firstAddrPosition).getChildren()));
                    rv2.scrollToPosition(secondAddrPosition);

                    if (thirdAddrPosition != -1 &&
                            business_districts.getBody().get(firstAddrPosition).getChildren() != null &&
                            business_districts.getBody().get(firstAddrPosition).getChildren().size() > 0 &&
                            business_districts.getBody().get(firstAddrPosition).getChildren().get(secondAddrPosition).getChildren() != null &&
                            business_districts.getBody().get(firstAddrPosition).getChildren().get(secondAddrPosition).getChildren().size() > 0) {

                        business_districts.getBody().get(firstAddrPosition).getChildren().get(secondAddrPosition).getChildren().get(thirdAddrPosition).setSelect(true);
                        findMinSulChooseAddr3Adapter.setData(business_districts.getBody().get(firstAddrPosition).getChildren().get(secondAddrPosition).getChildren());
                        rv3.scrollToPosition(thirdAddrPosition);
                        rv3.setVisibility(View.VISIBLE);
                    } else {
                        rv3.setVisibility(View.GONE);
                    }
                }
            }

        }/*else {
            if (business_districts.getBody() != null && business_districts.getBody().size() > 0) {
                business_districts.getBody().get(0).setSelect(true);
                findMinSulChooseAddr3Adapter.notifyDataSetChanged();
                rv1.scrollToPosition(0);

                if ( business_districts.getBody().get(0).getChildren() != null && business_districts.getBody().get(0).getChildren().size() > 0) {
                    business_districts.getBody().get(0).getChildren().get(0).setSelect(true);

                    findMinSulChooseAddr2Adapter.setData((body.get(0).getChildren()));
                    rv2.scrollToPosition(0);

                    if (
                            business_districts.getBody().get(0).getChildren() != null &&
                                    business_districts.getBody().get(0).getChildren().size() > 0 &&
                                    business_districts.getBody().get(0).getChildren().get(0).getChildren() != null &&
                                    business_districts.getBody().get(0).getChildren().get(0).getChildren().size() > 0) {

                        business_districts.getBody().get(0).getChildren().get(0).getChildren().get(0).setSelect(true);
                        findMinSulChooseAddr3Adapter.setData(business_districts.getBody().get(0).getChildren().get(0).getChildren());
                        rv3.scrollToPosition(0);

                    } else {
                        rv3.setVisibility(View.GONE);
                    }
                }
            }
        }*/

    }

    private void diasspopu() {
        if (popuMore != null && popuMore.getPopupWindow() != null) {
            popuMore.getPopupWindow().dismiss();
            popuMore = null;

        }
        if (popuSort != null && popuSort.getPopupWindow() != null) {
            popuSort.getPopupWindow().dismiss();
            popuSort = null;
        }
        if (popuAddr != null) {
            popuAddr.getPopupWindow().dismiss();
            popuAddr = null;
        }
        if (popuaddr3Ji != null && popuaddr3Ji.getPopupWindow() != null) {
            popuaddr3Ji.getPopupWindow().dismiss();
            popuaddr3Ji = null;


        }
    }

    private void getMore(View view) {
        switch (view.getId()) {
            case R.id.tv_default: {//默认排序
                popuSort();

            }
                /*ChooseDefalutDialog chooseDefalutDialog = ChooseDefalutDialog.newInstance();
                chooseDefalutDialog.show(getFragmentManager());*/

            break;
            case R.id.tv_type: {//房源类型
                tvType.setSelected(true);
                final CustomPopupWindow builder1 = new CustomPopupWindow.Builder().setheight(LinearLayoutCompat.LayoutParams.MATCH_PARENT)
                        .setwidth(LinearLayoutCompat.LayoutParams.MATCH_PARENT)
                        .setOutSideCancel(false)
                        .setActivity(this)
                        .isBlur(true)
                        .setRadius(5)
                        .setContext(this)
                        .setContentView(R.layout.popu_bourn_head_chose_addr_sort)
                        .setOnDismissListener(new PopupWindow.OnDismissListener() {
                            @Override
                            public void onDismiss() {
                                tvType.setSelected(false);
                            }
                        })
                        .builder();

                builder1.getItemView(R.id.close).setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        builder1.dismiss();
                        if (popuaddr3Ji != null && popuaddr3Ji.getPopupWindow() != null) {
                            popuaddr3Ji.getPopupWindow().dismiss();
                            popuaddr3Ji = null;
                        }
                        if (popuMore != null && popuMore.getPopupWindow() != null) {
                            popuMore.getPopupWindow().dismiss();
                            popuMore = null;

                        }
                        if (popuSort != null && popuSort.getPopupWindow() != null) {
                            popuSort.getPopupWindow().dismiss();
                            popuSort = null;

                        }
                        if (popuAddr != null && popuAddr.getPopupWindow() != null) {
                            popuAddr.getPopupWindow().dismiss();
                            popuAddr = null;

                        }
                    }
                });


                builder1.showAsLaction(ll_addrSort, Gravity.BOTTOM, 0, 0);

                RecyclerView rvAddr = (RecyclerView) builder1.getItemView(R.id.rv_addr_sort);
                rvAddr.setLayoutManager(new LinearLayoutManager(this));
                if (bournFiltersTypeAdapter == null) {
                    bournFiltersTypeAdapter = new BournFiltersTypeAdapter(this);

                }
                if (houses_filtersEntity != null && houses_filtersEntity.getBody() != null && "200".equals(houses_filtersEntity.getCode())) {
                    bournFiltersTypeAdapter.setData(houses_filtersEntity.getBody().getTypes());
                }
                rvAddr.setAdapter(bournFiltersTypeAdapter);

                rvAddr.addItemDecoration(new RVItemDecoration(LinearLayout.VERTICAL, PhoneUtil.dp2px(this, 1), getResources().getColor(R.color.colorBg), PhoneUtil.dp2px(this, 8)));
                bournFiltersTypeAdapter.setOnItemClickListener(new AbsRecyclerViewAdapter.OnItemClickListener() {
                    @Override
                    public void onItemClick(View v, int position) {
                        if (houses_filtersEntity != null && houses_filtersEntity.getBody() != null) {
                            houses_filtersEntity.getBody().getTypes().get(position).setCheck(!houses_filtersEntity.getBody().getTypes().get(position).isCheck());

                            if (currentTypePosition != -1 && currentTypePosition != position) {
                                houses_filtersEntity.getBody().getTypes().get(currentTypePosition).setCheck(!houses_filtersEntity.getBody().getTypes().get(currentTypePosition).isCheck());

                            }
                            if (houses_filtersEntity.getBody().getTypes().get(position).isCheck()) {
                                types = houses_filtersEntity.getBody().getTypes().get(position).getId();
                                if (position == 0) {
                                    tvType.setText("位置区域");

                                } else {
                                    tvType.setText(houses_filtersEntity.getBody().getTypes().get(position).getName());
                                }
                                currentTypePosition = position;
                            } else {
                                tvType.setText("位置区域");

                                types = "";
                                currentTypePosition = -1;

                            }
                            bournFiltersTypeAdapter.notifyDataSetChanged();
                            loadingDialog = LoadingDialog.newInstance("加载中");
                            loadingDialog.show(getFragmentManager(), "loading");
                            onRefresh();
                        }

                    }
                });
       /* View inflate = View.inflate(getContext(), R.layout.recycle_head, null);
        homeListSaleAdapter.addHeaderView(inflate);*/
                bournFiltersTypeAdapter.setEmptyView(R.layout.empty_tips);
                bournFiltersTypeAdapter.setEmptyTips(R.id.tv_emptyTips, "没有更多了");

            }
            break;
            case R.id.tv_more: {//更多筛选
                popuMore();


            }
            break;

        }


    }


    @Override
    public void onResponse(String url, String json) {
        if (statusLayoutManager != null) {
            statusLayoutManager.showSuccessLayout();

        }
        if (String.format(Constant.URL.villages, villageId).equals(url)) {
            LogeUtil.e("villages", json);
            villagesEntity = gson.fromJson(json, VillagesEntity.class);
            if (villagesEntity.getBody() != null && "200".equals(villagesEntity.getCode())) {
                initView();
            }
        } else if (Constant.URL.houses_list.equals(url)) {
            dismissLoading();
            LogeUtil.e("houses_list", json);
            Find_House_minsu_listEntity houses_listEntity = gson.fromJson(json, Find_House_minsu_listEntity.class);
            removeLoadingItem();
            if (pageNo == 1) {
                data.clear();
            }

            if ("200".equals(houses_listEntity.getCode()) && houses_listEntity.getBody() != null) {
                data.addAll(houses_listEntity.getBody().getList());
                if (data.size() > 0) {
                    data.get(0).setMyType(4);
                }
                if (houses_listEntity.getBody().isHasNext()) {
                    data.add(new Find_House_minsu_listEntity.BodyEntity.ListEntity(1));
                    nextIndex = pageNo + 1;

                } else {
                    addBaseLine();
                }

            } else {
                addBaseLine();
            }
            bournDeticalAdapter.setData(data);
            if (pageNo == 1 && data.size() > 0) {
                rvDataList.scrollToPosition(0);
            }
        } else if (Constant.URL.houses_filters.equals(url)) {
            dismissLoading();
            LogeUtil.e("houses_filters", json);
            houses_filtersEntity = gson.fromJson(json, Houses_filtersEntity.class);

            if (houses_filtersEntity != null && houses_filtersEntity.getBody() != null && "200".equals(houses_filtersEntity.getCode())) {
                getMore(currentView);

            }

        } else if (Constant.URL.business_districts.equals(url)) {
            dismissLoading();
            LogeUtil.e("business_districts", json);
            business_districts = gson.fromJson(json, Business_districts.class);
            if ("200".equals(business_districts.getCode())) {
                initAddr3ji(business_districts.getBody());
            }

        } else if (String.format(Constant.URL.cities_areas, AppContext.currentCityidCurrent).equals(url)) {
            dismissLoading();
            LogeUtil.e("cities_areas", json);
            cities_areasEntity = gson.fromJson(json, Cities_areasEntity.class);
            if ("200".equals(cities_areasEntity.getCode()) && cities_areasEntity.getBody() != null) {
                popuAddr = new CustomPopupWindow.Builder().setheight(LinearLayoutCompat.LayoutParams.MATCH_PARENT)
                        .setwidth(LinearLayoutCompat.LayoutParams.MATCH_PARENT)
                        .setOutSideCancel(false)
                        .setContext(this)
                        .isBlur(true)
                        .setRadius(5)
                        .setActivity(this)
                        .setContentView(R.layout.popu_find_house2_addr_sort)
                        .setOnDismissListener(new PopupWindow.OnDismissListener() {
                            @Override
                            public void onDismiss() {
                                tvType.setSelected(false);

                            }
                        })
                        .builder();

                popuAddr.getItemView(R.id.close).setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        popuAddr.dismiss();
                        if (popuaddr3Ji != null && popuaddr3Ji.getPopupWindow() != null) {
                            popuaddr3Ji.getPopupWindow().dismiss();
                            popuaddr3Ji = null;
                        }
                        if (popuMore != null && popuMore.getPopupWindow() != null) {
                            popuMore.getPopupWindow().dismiss();
                            popuMore = null;

                        }
                        if (popuSort != null && popuSort.getPopupWindow() != null) {
                            popuSort.getPopupWindow().dismiss();
                            popuSort = null;

                        }
                        if (popuAddr != null && popuAddr.getPopupWindow() != null) {
                            popuAddr.getPopupWindow().dismiss();
                            popuAddr = null;

                        }
                    }
                });
                RecyclerView rvAddr = (RecyclerView) popuAddr.getItemView(R.id.rv_addr_sort);
                rvAddr.setLayoutManager(new LinearLayoutManager(this));
                bournlistHeadAddrSortAdapter = new BournlistHeadAddrSortAdapter(this);
                rvAddr.setAdapter(bournlistHeadAddrSortAdapter);

                rvAddr.addItemDecoration(new RVItemDecoration(LinearLayout.VERTICAL, PhoneUtil.dp2px(this, 1), getResources().getColor(R.color.colorBg), PhoneUtil.dp2px(this, 8)));
                bournlistHeadAddrSortAdapter.setOnItemClickListener(new AbsRecyclerViewAdapter.OnItemClickListener() {
                    @Override
                    public void onItemClick(View v, int position) {

                        popuAddr.dismiss();
                        if (popuaddr3Ji != null && popuaddr3Ji.getPopupWindow() != null) {
                            popuaddr3Ji.getPopupWindow().dismiss();
                            popuaddr3Ji = null;
                        }
                        if (popuMore != null && popuMore.getPopupWindow() != null) {
                            popuMore.getPopupWindow().dismiss();
                            popuMore = null;

                        }
                        if (popuSort != null && popuSort.getPopupWindow() != null) {
                            popuSort.getPopupWindow().dismiss();
                            popuSort = null;

                        }
                        if (popuAddr != null && popuAddr.getPopupWindow() != null) {
                            popuAddr.getPopupWindow().dismiss();
                            popuAddr = null;

                        }

                        if (qudatas != null && qudatas.size() > 0) {
                            qudatas.get(position).setCheck(!qudatas.get(position).isCheck());

                            if (currentAddPosition != -1 && currentAddPosition != position) {
                                qudatas.get(currentAddPosition).setCheck(!qudatas.get(currentAddPosition).isCheck());

                            }
                            if (qudatas.get(position).isCheck()) {
                                area = qudatas.get(position).getName();

                                tvType.setText("全部".equals(qudatas.get(position).getName())?"位置区域":qudatas.get(position).getName());
                                currentAddPosition = position;
                            } else {
                                tvType.setText("位置区域");

                                area = "";
                                currentAddPosition = -1;

                            }
                            bournlistHeadAddrSortAdapter.notifyDataSetChanged();
                            loadingDialog = LoadingDialog.newInstance("加载中");
                            loadingDialog.show(getFragmentManager(), "loading");
                            onRefresh();
                        }

                    }
                });
       /* View inflate = View.inflate(getContext(), R.layout.recycle_head, null);
        homeListSaleAdapter.addHeaderView(inflate);*/
                bournlistHeadAddrSortAdapter.setEmptyView(R.layout.empty_tips);
                bournlistHeadAddrSortAdapter.setEmptyTips(R.id.tv_emptyTips, "没有更多了");


                popuAddr.showAsLaction(ll_addrSort, Gravity.BOTTOM, 0, 0);

                qudatas.clear();
                qudatas.add(new Cities_areasEntity.BodyEntity("全部", ""));
                qudatas.addAll(cities_areasEntity.getBody());
                if (currentAddPosition != -1) {
                    qudatas.get(currentAddPosition).setCheck(true);

                } else {
                    qudatas.get(0).setCheck(true);
                }
                bournlistHeadAddrSortAdapter.setData(qudatas);

            }

        } else if (Constant.URL.modules_search_result_configurations.equals(url)) {//头部tag标签
            LogeUtil.e("modules_search_result_configurations", json);
            modules_find_house_configurations = gson.fromJson(json, Modules_find_house_configurations.class);
            if ("200".equals(modules_find_house_configurations.getCode())) {
                findHouseTagsAdapter.setData(modules_find_house_configurations.getBody().getTags());
            }

        } else if (Constant.URL.modules_find_house_configurations.equals(url)) {//暂时无用
            LogeUtil.e("modules_find_house_configurations", json);
            modules_find_house_configurations = gson.fromJson(json, Modules_find_house_configurations.class);
            if ("200".equals(modules_find_house_configurations.getCode())) {
                findHouseTagsAdapter.setData(modules_find_house_configurations.getBody().getTags());
            }

        }
    }


    private void removeLoadingItem() {
        if (data.size() > 0) {
            if (data.get(data.size() - 1).getMyType() == 1) {
                data.remove(data.size() - 1);
            }
        }
    }

    private void addBaseLine() {
        if (pageNo != 1) {
            data.add(new Find_House_minsu_listEntity.BodyEntity.ListEntity(2));
        }
    }

    @TargetApi(Build.VERSION_CODES.KITKAT)
    private void initView() {

    }

    @Override
    public void onFailure(String url, String error) {
        dismissLoading();
        if (statusLayoutManager != null) {

            statusLayoutManager.showErrorLayout();
        }
        ToastUtil.initToast(this, "网络错误");
    }

    private void dismissLoading() {
        if (loadingDialog != null) {
            loadingDialog.dismiss();
        }
        if (srl != null && srl.isRefreshing()) {
            srl.setRefreshing(false);
        }

    }
    private void initSharePop() {
        mRxManager.on("sharepopEntity", new Consumer<AllPostersEntity.BodyBean>() {

            @Override
            public void accept(AllPostersEntity.BodyBean bodyBean) throws Exception {

                allPostersEntity = bodyBean;
            }
        });
        mRxManager.on("sharepop", new Consumer<ImageWatcher>() {
            @Override
            public void accept(ImageWatcher imageWatcher) throws Exception {
                vImageWatcher = imageWatcher;
                vImageWatcher.setImageWatcherOndismiss(new ImageWatcher.ImageWatcherDiss() {
                    @Override
                    public void onImageWatcherDiss() {
                        if (allPostersEntity!=null){
                            ShareActivityNoWhitePop sharePop = new ShareActivityNoWhitePop(MinsuSearchResultActivity.this, MinsuSearchResultActivity.this, allPostersEntity);
                            sharePop.showPopupWindow();
                        }
                    }
                });
            }
        });
    }

    @TargetApi(Build.VERSION_CODES.KITKAT)
    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.tv_tuiguang://推荐
                ////2 小区，3 房源 ，7 酒店，52 特卖(预售)
                ShareUtils.getDataActivityNoWhite( this, "3",data.get((Integer) view.getTag()).getId()+"");

               /* Intent intent = new Intent(this, HouseDetailsActivityFor3.class);
                intent.putExtra("type", 1);
                intent.putExtra("houseId", data.get((Integer) view.getTag()).getId());
                intent.putExtra("presellProduct", false);

                intent.putExtra("brokerAge", data.get((Integer) view.getTag()).getBrokerAgeAmountValue());
                intent.putExtra("persellId", data.get((Integer) view.getTag()).getId());
                startActivity(intent);*/
                /*loadingDialog = LoadingDialog.newInstance("跳转中");
                loadingDialog.show(getFragmentManager(), "loading");
                String villageId = data.get((Integer) view.getTag()).getId();

                OkHttpUtil.getJSON(this, String.format(Constant.URL.vips_villages_posters, villageId), new OkHttpUtil.OnDataListener() {
                    @Override
                    public void onResponse(String url, String json) {
                        if (!TextUtils.isEmpty(json)) {
                            dismissLoading();
                            Material_postersEntity material_postersEntity = gson.fromJson(json, Material_postersEntity.class);
                            if ("200".equals(material_postersEntity.getCode())) {
                                LogeUtil.e("material_posters" + json);
                                ErWeiMaDialog erWeiMaDialog = ErWeiMaDialog.newInstance(material_postersEntity.getBody().getPoster());
                                erWeiMaDialog.show(getFragmentManager());

                                erWeiMaDialog.setOnItemClickListener(SearchBournForHouseActivity.this);
                            } else {
                                ToastUtil.initToast(SearchBournForHouseActivity.this, material_postersEntity.getMsg());
                            }
                        }

                    }

                    @Override
                    public void onFailure(String url, String error) {

                    }
                });*/

                break;
        }
    }

    @Override
    public void onCallback() {
        if (nextIndex == pageNo + 1) {
            pageNo++;
            getHouseList();
        }
    }

    @Override
    public void onItemClick(View v, int position) {
        Intent intent = new Intent(this, HouseDetailsActivityFor3.class);
        intent.putExtra("type", 0);
        intent.putExtra("houseId", data.get(position).getId());
        intent.putExtra("presellProduct", false);

        intent.putExtra("brokerAge", data.get(position).getBrokerAgeAmountValue());
        intent.putExtra("persellId", data.get(position).getId());
        startActivity(intent);
    }

    @Override
    public void onRefresh() {


        tv_choseCity.setText(AppContext.cityCurrent);
        pageNo = 1;
        nextIndex = 1;
        getHouseList();
    }


    @Override
    public void onItemClick(View v) {
        switch (v.getId()) {

            case R.id.tv_wx: {
                loadingDialog = LoadingDialog.newInstance("加载中");
                loadingDialog.show(getFragmentManager(), "loading");
                List<String> images = new ArrayList<>();
                images.add((String) v.getTag());
                ShareUtilse.shareImage(MinsuSearchResultActivity.this, 0, images, images.get(images.size() - 1),"");

            }
            break;
            case R.id.tv_pyq: {
                loadingDialog = LoadingDialog.newInstance("加载中");
                loadingDialog.show(getFragmentManager(), "loading");
                List<String> images = new ArrayList<>();
                images.add((String) v.getTag());
                ShareUtilse.shareImage(MinsuSearchResultActivity.this, 1, images, images.get(images.size() - 1),"");

            }
            break;
            case R.id.tv_save: {
                saveImageToSdCard(this, (String) v.getTag(), true);
                ToastUtil.initToast(this, "保存成功");
            }
            break;
        }
    }


    //根据网络图片url路径保存到本地
    public static final File saveImageToSdCard(Context context, String image, boolean isxiangce) {
        boolean success = false;
        File file = null;
        try {
            if (isxiangce) {
                file = createXiangCeImageFile(context);
            } else {
                file = createStableImageFile(context);

            }

            Bitmap bitmap = null;
            URL url = new URL(image);
            HttpURLConnection conn = null;
            conn = (HttpURLConnection) url.openConnection();
            InputStream is = null;
            is = conn.getInputStream();
            bitmap = BitmapFactory.decodeStream(is);

            FileOutputStream outStream;

            outStream = new FileOutputStream(file);
            bitmap.compress(Bitmap.CompressFormat.PNG, 100, outStream);
            outStream.flush();
            outStream.close();
            success = true;
            //MediaStore.Images.Media.insertImage(context.getContentResolver(), image, file.getName(), "你对图片的描述");

        } catch (Exception e) {
            e.printStackTrace();
        }

        if (success) {
            return file;
        } else {
            return null;
        }
    }

    public static String IMAGE_NAME = "iv_share_";
    public static int i = 0;

    //创建相册
    public static File createXiangCeImageFile(Context context) throws IOException {
        String imageFileName = IMAGE_NAME + ".jpg";

        String fileName;
        File file;
        if (Build.BRAND.equals("Xiaomi")) { // 小米手机
            fileName = Environment.getExternalStorageDirectory().getPath() + "/DCIM/Camera/" + imageFileName;
        } else {  // Meizu 、Oppo
            fileName = Environment.getExternalStorageDirectory().getPath() + "/DCIM/Camera/" + imageFileName;
        }
        file = new File(fileName);

        if (file.exists()) {
            file.delete();
        }
        return file;
    }

    //创建本地保存路径
    public static File createStableImageFile(Context context) throws IOException {

        i++;
        String imageFileName = IMAGE_NAME + System.currentTimeMillis() + ".jpg";
        File storageDir = context.getExternalCacheDir();
        File image = new File(storageDir, imageFileName);
        return image;
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == RESULT_OK) {
            if (requestCode == 123) {//城市搜索


                city = data.getStringExtra("cityName");
                tv_choseCity.setText(city);

                tvType.setText("位置区域");

                area = "";
                AppContext.currentCityidCurrent = data.getStringExtra("cityId");
                ;//当前城市id
                AppContext.cityCurrent = city;//当前城市

               // onRefresh();


                //重置更多
                minPriceCurrent = 0;
                if (tickMarkTextArray != null) {
                    maxPriceCurrent = tickMarkTextArray.length - 1;

                }
                peoplesCurrent = 0;
                onChangePeoplesCurrent = 0;
                facilitiespositionS.clear();
                if (tagAdapter != null) {
                    tagAdapter.setSelectedList(facilitiespositionS);

                }
                //重置三级
                addrId = "";
                firstAddrPosition = 0;//地址选择第一级选中position
                secondAddrPosition = 0;
                thirdAddrPosition = 0;
                //重置排序
                tvDefault.setText("默认排序");

                sortBy = "";
                if (currentSortPosition != -1) {
                    houses_filtersEntity.getBody().getSorts().get(currentSortPosition).setCheck(false);

                }
                currentSortPosition=-1;

                currentTypePosition = -1;
                tvType.setText("位置区域");
//重置位置区域
                currentAddPosition = -1;

                //重置标签
                for (int i = 0; i < modules_find_house_configurations.getBody().getTags().size(); i++) {
                    modules_find_house_configurations.getBody().getTags().get(i).setCheck(false);

                }
                findHouseTagsAdapter.notifyDataSetChanged();
                loadingDialog = LoadingDialog.newInstance("加载中");
                loadingDialog.show(getFragmentManager(), "loading");
                onRefresh();
            }
        }
    }

    @Override
    public void beforeTextChanged(CharSequence s, int start, int count, int after) {

    }

    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {
        CharSequence text = s;
        if (!TextUtils.isEmpty(text)) {
            minPriceCurrent = 0;
            if (tickMarkTextArray != null && tickMarkTextArray.length >= 1) {
                maxPriceCurrent = tickMarkTextArray.length - 1;

            }
            peoplesCurrent = 0;

            onChangePeoplesCurrent = 0;
            facilitiespositionS.clear();
            if (tagAdapter != null) {
                tagAdapter.setSelectedList(facilitiespositionS);

            }

            words = text.toString();

        } else {
            words = "";

        }
        loadData();

    }

    @Override
    public void afterTextChanged(Editable s) {

    }

    @OnClick(R.id.toolbar_back1)
    public void onViewClicked() {
        onBackPressed();
    }
}



